<template>
	<view class="bg-white h_100">
		<view v-if="!info" class="p-2" style="margin:auto;"><u-empty mode="data" icon="http://cdn.uviewui.com/uview/empty/data.png" text="暂无详情内容"></u-empty></view>
		<view v-else>
			<view class=" p-2">
				<view class="my-1 h3 font-weight-bold">{{ info.title }}</view>
				<view class="font_24 c_9">活动时间：{{ info.add_time }}</view>
			</view>
			<view class="p-2 view"><u-parse :content="info.content"></u-parse></view>
		</view>
	</view>
</template>
<script>
import { getZhanNewsDetail } from '@/api/home/company.js';
export default {
	data() {
		return {
			info: {},
			infoId:''
		};
	},
	onLoad(option) {
		this.infoId = option.id
		this.getInfo(option.id);
		// 分享
		wx.showShareMenu({
			withShareTicket: true,
			menus: ['shareAppMessage', 'shareTimeline']
		});
	},
	//分享到聊天
	onShareAppMessage(res) {
		return {
			title: this.info.title,
			path: '/subPages/company_home/info_detail?id=' + this.infoId, //界面路径
			imageUrl: this.info.imglist || '/static/img2/home/logo.jpg'
		};
	},
	// 分享到朋友圈
	onShareTimeline() {
		return {
			title: this.info.title,
			path: '/subPages/company_home/info_detail?id=' + this.infoId, //界面路径
			imageUrl: this.info.imglist || '/static/img2/home/company_head.png'
		};
	},
	methods: {
		getInfo(val) {
			let msg = {
				id: val,
				uid: uni.getStorageSync('userInfo').userId || ''
			};
			getZhanNewsDetail(msg)
				.then(res => {
					// console.log(res);
					if (res.code == 0) {
						this.info = res.data;
					} else {
						uni.$u.toast(res.msg);
					}
				})
				.catch(err => {
					console.log('获取案例详情失败', err);
				});
		}
	}
};
</script>

<style>
::v-deep ._img{
	margin: 20rpx 0;
}
</style>
